package com.tms.springboot.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import com.tms.springboot.aggregation.pojo.PdOrder;
import com.tms.springboot.result.JsonResult;
import com.tms.springboot.result.ResultTool;
import com.tms.springboot.service.PdTransportOrderService;
import com.tms.springboot.aggregation.pojo.PdTransportOrder;
import com.tms.springboot.view.PageVo;
import com.tms.springboot.vo.PdTransportOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 运单表 前端控制器
 * </p>
 *
 * @author cjj
 * @since 2023-06-14
 */
@RestController
@RequestMapping("/pd-transport-order")
public class PdTransportOrderController {


    @Autowired
    private PdTransportOrderService service;

    @RequestMapping("/queryPdTransportOrderByOrderId/{orderId}")
    public JsonResult queryPdTransportOrderByOrderId(@PathVariable String orderId) {
        LambdaQueryWrapper<PdTransportOrder> queryWrapper=new LambdaQueryWrapper<>();
        if (StringUtil.isEmpty(orderId)) {
            queryWrapper.eq(PdTransportOrder::getOrderId,orderId);
        }
        PdTransportOrder one = this.service.getOne(queryWrapper);
        return one != null ? ResultTool.success(one) : ResultTool.fail();
    }

    @RequestMapping("/queryPdTransportOrderPage")
    public JsonResult queryPdTransportOrderPage(@RequestBody PageVo<PdOrder> queryPdOrder){
        List<PdTransportOrderVo> queryPdTransportOrderPage = this.service.getQueryPdTransportOrderPage(queryPdOrder);
        return queryPdTransportOrderPage !=null ? ResultTool.success(new PageInfo<>(queryPdTransportOrderPage)) : ResultTool.fail();
    }



}
